<template>
	<view class="box">
		<!-- <uNavbar title="开箱记录" :bgColor="backgroundColor" :titleStyle="titleStyle" leftIconColor="#ffffff"  ></uNavbar> -->
		<view class="back flex_c">
			<image src="../../static/icon/left_jt.png" mode="aspectFill" @click="goBack"></image>
			<!-- <text>开箱记录</text> -->
		</view>
		<view  style="width: 100%;height: 120rpx;"></view>
		<view class="main">
			<view class="item" v-for="(item,index) in slist" :key="item.id">
				<view class="top" >
					开箱时间：{{item.create_time}}
				</view>
				<view class="bot">
					<view class="bot_item">
						<image :src="item.goods_image" mode=""></image>
						<view class="txt">
							<view class="txt-top">
								{{item.goods_name}}*{{item.goods_number}}
							</view>
							<view class="txt-bot" @click="gomy(item.receive_member)" >
							点击查看
							</view>
						</view>
					</view>
					<view class="bot_item">
						<image :src="item.guessing_image" mode=""></image>
						<view class="txt">
							<view class="txt-top">
								{{item.guessing_name}}*{{item.guessing_number}}
							</view>
							<view class="txt-bot" @click="guessingCard">
							点击查看
							</view>
						</view>
					</view>
				</view>
			</view>
			<noDatas :xxxList="slist" class="ssss"  :status="status"></noDatas>
		</view>
		<u-popup :show="show3" mode="center" @close="show3=false" closeable bgColor="transparent">
			<view class="zz_wrap">
				<view class="tit">
					奖励已发放至
				</view>
				<view class="ipt">
					<input type="text"  v-model.trim="account1"   />
				</view>
				<view class="ipt">
					<input type="number" v-model.trim="phone1"  />
				</view>
				<view class="zz_btn" v-if="!showzz" @click="show3=false">
					确认
				</view>
		
			</view>
		</u-popup>
		<u-popup :show="show2" mode="center" @close="show2=false" closeable bgColor="transparent">
			<view class="zz_wrap">
				<view class="tit">
					领取奖励
				</view>
				<view class="ipt">
					<input type="text"  v-model.trim="account" placeholder="请输入对方账号"  />
				</view>
				<view class="ipt">
					<input type="number" v-model.trim="phone" placeholder="请输入对方手机号" />
				</view>
				<view class="zz_btn" v-if="!showzz" @click="getotherinfo">
					确认
				</view>

			</view>
		</u-popup>
	</view>
</template>

<script>
	import {openRecord,give} from "../../api/shopp.js"
	import {
		phoneMemberInfo,
	} from "../../api/object.js"
	export default {
		data() {
			return {
				backgroundColor: "transparent", //标题背景颜色
				page: 1,
				size: 20,
				status: 'loadmore', //加载前值为loadmore，加载中为loading，没有数据为nomore
				slist:[],
				showzz: false,
				show2:false,
				phone:"",
				account:"",
				phone1:"",
				account1:"",
				ids:"",
				show3:false,
				titleStyle: {
					color: '#ffffff'
				},
			}
		},
		onLoad() {
			this.getList()
		},
		methods: {
			getotherinfo() {
				if (!this.phone) {
					uni.$u.toast("手机号不能为空")
				}else if (!this.account) {
					uni.$u.toast("手机号不能为空")
				} else {
					give({
						account:this.account,
						phone: this.phone,
						guessing_coupon_id:this.ids
					}).then(res => {
						if (res.code == 1) {
							this.page=1
							this.getList()
							
							uni.$u.toast(res.msg)
							this.show2=false
						}
						uni.$u.toast(res.msg)
						console.log(res)
					})
				}
			
			},
			goBack() {
				//获取页面栈的长度
				const canNavBack = getCurrentPages()
				console.log(canNavBack.length);
				// 判断是否刷新了浏览器，刷新了浏览器，页面栈只有当前一个
				if (canNavBack.length > 1) {
					uni.navigateBack({
						delta: 1
					})
				} else {
					uni.switchTab({
						url: '/pages/index/index'
					})
				}
			},
			hideMiddleDigits(phoneNumber) {
				// 获取手机号的前三位
				const firstPart = phoneNumber.substring(0, 3);
				// 获取手机号的后四位
				const lastPart = phoneNumber.substring(7);
				// 将中间四位替换为 ****
				const hiddenDigits = phoneNumber.substring(3, 7).replace(/\d/g, '*');
				// 拼接前三位、中间四位替换后的内容和后四位
				const hiddenNumber = firstPart + hiddenDigits + lastPart;
				return hiddenNumber;
			},
			guessingCard(){
				uni.navigateTo({
					url:'/pagesMy/activityCenter/activityZone'
				})
			},
			gomy(item){
			uni.switchTab({
				url:"/pages/index/my"
			})
			uni.setStorageSync("typessss",2)
				// this.show3=true
				// this.account1=item.account
				// this.phone1=item.phone
				// console.log(item)
			},
				getList(){
					openRecord({
						page:this.page
					}).then(res=>{
						if (res.code == 1) {
							let list = res.data.data;
							this.slist = this.page == 1 ? list : this.slist.concat(list);
							console.log(this.slist);
							if (list.length < this.size) this.status = 'nomore';
							else this.status = 'loading';
						}
				
					})
				},
			onPageScroll: function(e) {
				const scrollTop = e.scrollTop; // 获取页面滚动位置
				// 根据滚动位置修改状态栏样式
				if (scrollTop > 100) {
					this.backgroundColor = '#E0DDDA';
					this.titles = '详情';
				} else {
					this.backgroundColor = 'transparent';
					this.titles = '';
				}
				// console.log("滚动距离为：" + e.scrollTop);
			},
		},
		onReachBottom() {
			if (this.status != 'nomore') {
				this.page = this.page + 1
				this.getList()
			}
		},
	}
</script>
<style>
	page{
		background-color: #FC5B4B;
	}
</style>
<style scoped lang="scss">
	
	.back {
		position: fixed;
		top: 30rpx;
		/* #ifdef APP */
		top: 60rpx;
		/* #endif */
		left: 20rpx;
		width: 100%;
		height: 88rpx;
		z-index: 999;
	}
	
	.back>text {
		font-size: 28rpx;
		/* #ifdef APP */
		font-size: 36rpx;
		/* #endif */
		color: #ffffff;
	}
	
	.back>image {
		position: absolute;
		top: 50%;
		left: 0;
		transform: translateY(-50%);
		width: 60rpx;
		height: 60rpx;
	}
	.box {
		width: 100%;
		height: 2202rpx;
		background-image: url("../../static/image/boxbg.png");
		background-size: 100% 100%;
		position: relative;
		
	}
	.main{
		width: 704rpx;
		 min-height: 898rpx;
		background: #FEF2E4;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		margin: 0 auto;
		padding-bottom:20rpx ;
	}
	.ssss{
		padding-top: 120rpx !important;
	}
	.item{
		width: 644rpx;
		height: 400rpx;
		margin:  0 auto;
		padding-top: 20rpx;
		.top{
			width: 644rpx;
			height: 58rpx;
			background: linear-gradient( 270deg, #FC6947 0%, #FD896F 98%);
			border-radius: 20rpx 20rpx 0rpx 0rpx;
			padding-left: 5rpx;
			font-weight: 400;
			font-size: 30rpx;
			color: #FFFFFF;
			padding-top: 5rpx;
			padding-left: 20rpx;
		}
		.bot{
			width: 644rpx;
			height: 300rpx;
			background: #FFFFFF;
			border-radius: 0rpx 0rpx 16rpx 16rpx;
			display: flex;
			flex-direction: column;
			padding-top: 10rpx;
			justify-content: space-around;
			
			.bot_item{
					width: 100%;
					display: flex;
					justify-content: space-around;
					align-items: center;
				>image{
					width: 100rpx;
					height: 100rpx;
					border-radius: 18rpx 18rpx 18rpx 18rpx;
				}
				.txt{
					.txt-top{
						width: 450rpx;
						font-weight: 500;
						font-size: 28rpx;
						color: #666666;
						// white-space: nowrap;        /* 文本不换行 */
						//             overflow: hidden;           /* 隐藏超出部分 */
						//             text-overflow: ellipsis; 
					}
					.txt-bot{
						width: 150rpx;
						height: 40rpx;
						background: #FF5F4A;
						border-radius: 416rpx 416rpx 416rpx 416rpx;
						margin-top: 8rpx;
						font-weight: 500;
						font-size: 24rpx;
						color: #FFFFFF;
						text-align: center;
						line-height: 40rpx;
					}
				}
			}
		}
	}
	.zz_wrap {
		width: 602rpx;
		// height: 416rpx;
		background: #E0DDDA;
		border-radius: 22rpx 22rpx 22rpx 22rpx;
	
		.tit {
			width: 602rpx;
			text-align: center;
			font-size: 36rpx;
			color: #333;
			padding-top: 50rpx;
	
		}
	
		.ipt {
			width: 522rpx;
			height: 76rpx;
			background: #f2f2f2;
			border-radius: 410rpx 410rpx 410rpx 410rpx;
			margin: 0 auto;
			margin-top: 62rpx;
	
			>input {
				width: 502rpx;
				height: 76rpx;
				background: #f2f2f2;
				border-radius: 410rpx 410rpx 410rpx 410rpx;
				padding-left: 20rpx;
				font-size: 30rpx;
				color: #333;
			}
		}
	
		.zz_btn {
			width: 522rpx;
			height: 76rpx;
			background: linear-gradient( 274deg, #F9A569 0%, #F94A49 100%);
			border-radius: 410rpx 410rpx 410rpx 410rpx;
			margin: 0 auto;
			margin-top: 50rpx;
			margin-bottom: 62rpx;
			font-weight: 300;
			font-size: 30rpx;
			color: #FFFFFF;
			text-align: center;
			line-height: 76rpx;
		}
	
		.otherinfo {
			width: 522rpx;
			// height: 400rpx;
			padding-bottom: 40rpx;
			margin: 0 auto;
			margin-top: 48rpx;
	
			.otherinfo_tit {
				font-size: 28rpx;
				color: #333;
			}
	
			.otherinfowrap {
				width: 522rpx;
				height: 200rpx;
				position: relative;
				margin: 0 auto;
	
				>image {
					width: 100rpx;
					height: 100rpx;
					border-radius: 50%;
					margin-top: 46rpx;
				}
	
				.othername {
					width: 300rpx;
					height: 38rpx;
					font-family: Source Han Sans, Source Han Sans;
					font-weight: 400;
					font-size: 26rpx;
					color: #333;
					position: absolute;
					top: 34rpx;
					left: 128rpx;
				}
	
				.otherphone {
					width: 300rpx;
					height: 38rpx;
					font-family: Source Han Sans, Source Han Sans;
					font-weight: 400;
					font-size: 26rpx;
					color: #333;
					position: absolute;
					top: 80rpx;
					left: 128rpx;
				}
	
				.otherphone2 {
					width: 300rpx;
					height: 38rpx;
					font-family: Source Han Sans, Source Han Sans;
					font-weight: 400;
					font-size: 26rpx;
					color: #333;
					position: absolute;
					top: 124rpx;
					left: 128rpx;
				}
	
				.othernum {
					margin-top: 20rpx;
					font-size: 24rpx;
					color: #D7D6E1;
					white-space: nowrap;
					/* 不换行 */
					overflow: hidden;
					/* 超出部分隐藏 */
					text-overflow: ellipsis;
	
				}
			}
	
			.other_btnwrap {
				width: 522rpx;
				height: 72rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 70rpx;
	
				.other_btn1 {
					width: 220rpx;
					height: 72rpx;
					border-radius: 280rpx 280rpx 280rpx 280rpx;
					border: 2rpx solid #A68A64;
					font-size: 28rpx;
					color: #333;
					text-align: center;
					line-height: 72rpx;
				}
	
				.other_btn2 {
					width: 220rpx;
					height: 72rpx;
					background: linear-gradient( 274deg, #F9A569 0%, #F94A49 100%);
					border-radius: 280rpx 280rpx 280rpx 280rpx;
					font-size: 28rpx;
					color: #333;
					text-align: center;
					line-height: 72rpx;
				}
			}
		}
	}
</style>